<template>
  <!-- <div class="tab_box">
    <span class="tab_title is_active">{{title}}</span>
  </div> -->
  <div class="tab_box">
    <template v-for="(item, index) in tabs">
      <span class="tab_title " :class="{'is_active': item.name === active}" @click="handleClick(item)">{{item.text}}</span>
      <em class="spe" v-show="!(index === tablen)"></em>
    </template>
  </div>
</template>

<script>
export default {
  name: 'tab',
  props: {
    tabs: {
      type: Array
    },
    activeName: {
      type: String
    }
  },
  data () {
    return {
      active: this.activeName
    }
  },
  computed: {
    tablen () {
      return this.tabs.length - 1
    }
  },
  methods: {
    handleClick (item) {
      this.active = item.name
      this.$emit('tabClick', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.tab_box{
  width: 100%;
  overflow: hidden;
  position: relative;
  font-size: 0;
   
  // height: 40px;
  margin-bottom:21px;
  &::after {
    position: absolute;
    content: "";
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background-color: #ececec;
    z-index: 1;
  }
  .spe{
    width: 1px;
    height:15px;
    background:#dcdcdc;
    display:inline-block;
  }
}
.tab_title{
  position: relative;
  cursor: pointer;
  display: inline-block;
  width:120px;
  text-align: center;
  padding-bottom: 13px;
  // height: 40px;
  box-sizing: border-box;
  line-height: 25px;
  font-size: 18px;
  font-weight: 500;
   color: #666;
  transition: all;
  &:nth-child(odd){
  margin-left: 0
  }
  &.is_active{
    color: #333333;
    // border-bottom: 2px solid #333333;
    &:after{
      position: absolute;
      content: "";
      left: 0;
      bottom: 0;
      width: 120px;
      height: 2px;
      background-color: #333333;
      z-index: 2;
    }
  }
}
</style>
